When to Use Cursor Rules Instead of MCPs

Want Cursor's AI Agent to intelligently run your custom CLI tools without complex MCP setups or constant hand-holding? If only the AI could understand your tool's --help output, life would be much simpler. This lesson demonstrates exactly that, leveraging Cursor's "Rules" feature with the "Agent Requested" type. You'll learn to feed your CLI's help text directly into a rule, effectively teaching the AI to operate your custom commands through natural language.

Workflow demonstrated in this lesson:

  • Execute your custom CLI tool's --help command (e.g., ghx --help) and pipe its output to your clipboard (e.g., | pbcopy).
  • Create a "New Cursor Rule" (Cmd/Ctrl + Shift + P, then "New Cursor Rule").
  • Paste the copied help text into the main content area of the rule.
  • Set the "Rule Type" to "Agent Requested".
  • Provide a clear, concise "Description" (e.g., "Search GitHub") that will act as the trigger phrase for the AI.
  • In an Agent chat, prompt the AI using natural language that corresponds to your rule's description (e.g., "Search GitHub for examples of package.jsons using semantic-release").
  • Observe as the Agent uses the rule's help text to correctly formulate and run your custom CLI command.
  • Leverage the tool's output by further instructing the AI to generate or modify project files (e.g., create a package.json, .releaserc.json, or biome.json based on findings).

Key benefits:

  • Empowers Cursor's AI Agent to directly use your existing custom CLI tools without needing to modify the tools themselves.
  • Simple and intuitive setup: Uses your tool's own documentation (--help output) as the "API" for the AI.
  • Efficient context usage: The detailed help text for your tool is only loaded into the AI's context when your specific trigger phrase is detected.
  • Provides a straightforward and powerful alternative to MCPs for many CLI tool integration scenarios, especially when tools already have good help messages.
  • Enables complex, natural language-driven automation by combining custom tool execution with the AI's code generation and modification capabilities.

By using "Agent Requested" rules, you gain maximum control over how and when the AI interacts with your custom tools, making the Agent a more versatile and powerful assistant tailored to your specific command-line utilities.

Resources

https://www.npmjs.com/package/@johnlindquist/ghx

Share with a coworker

Transcript

[00:00] When you run the help command of any tool you have installed, I built a custom tool called ghx for scraping GitHub examples. It should give you enough information about how to use the tool so that you can just hand it over to AIs and allow them to invoke the tool. So I'm going to invoke help and pipe it to pbcopy to add it to the clipboard. And then with command-shift-p I'm going to type new cursor rule, hit enter, and call this rule ghx. I'm simply going to paste all of the content into this rule.

[00:27] Let's scooch this down. And then switch this over to agent requested. And I'm going to give the description of search GitHub. I'll hit save, close this out, then in any agent conversation I can say search GitHub for examples of package json's using semantic dash release. We'll paste that in, and once I hit enter the agent should infer that we have a rule right here that has that tool built into it and now the tool can be invoked based on how it understands your English query against the tool.

[00:58] So it's looking for files with the name of package.json that include the text of semantic release. Now that this is done we can scroll down see what it came up with and we can see how it explained from those examples that it found the various configuration options around semantic release. So then if we try another query we can say, now please search GitHub for examples of package jasons with semantic-release and also biome. And then please create a package jason based on those examples for me. Just hit enter here, sit back, and let a package jason magically appear based on a bunch of examples from online.

[01:36] So we'll go ahead and accept this. You can see we have biome already set up, we have release set up, we have all the dev dependencies set up, and while I'm here I'll ask please make sure and update all of the dev dependencies to their latest versions just because these are based on examples and I don't know how old those might be. It looks like they were already on the latest version so that's good. We have our plugin set up and the package manager snuck in because I do have in my custom rules to please use pnpm by default. And I'm going to ask it to please update the package manager field for pnpm to the latest version as well.

[02:11] That'll go ahead and find that and update it. And now this is all set up based on very common patterns found online. Then we could also say please search for configurations for semantic release on GitHub and bring those most common patterns into my project. Let that run and sit back and now it's creating a releaserc.json file. And then also please search for the most common biome configurations on GitHub and bring those in as well.

[02:33] All right so now we have our package.json, we have our biome.json file, we'll just accept everything. We have our release.json file, and obviously if you have existing projects where you want it to instead of creating new files apply common patterns to existing files that will work as well. And then just one final note, I hear a lot of people saying to build MCPs around tools like this. I definitely prefer the rules approach where the agent is simply aware of Search GitHub mapping to all of this and it won't bring in any of this context until it finds searchGitHub as part of the request, whereas MCPs and all their definitions, descriptions, parameters, and everything have to stay in context all the time. I've just found this to be a very simple solution and from a conceptual standpoint the idea of agent requested based on description is essentially what MCP is doing anyway, but here I get maximum control over what I want it to do.